package com.mjt.dongbao.common.base.interceptor;

import com.mjt.dongbao.common.base.annotation.TokenCheck;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description： 将解析注解的拦截器注入
 * @Author mjt
 * @Time 2022/1/13
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    /**
     *
     * @Description:  对是否需要拦截的请求路径的配置
     * @Author mjt
     * @Date 2022/1/15
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/umsMember/login")
                .excludePathPatterns("/umsMember/register")
                .excludePathPatterns("/captcha/**")
                .excludePathPatterns("/kCaptcha/**")
                .excludePathPatterns("/favicon.ico");
    }

    @Bean
    public TokenInterceptor tokenInterceptor(){
        return new TokenInterceptor();
    }
}
